(function (root, factory){ if(typeof define==='function'&&define.amd){ define(['moment', 'jquery'], function (moment, jquery){ if(!jquery.fn) jquery.fn={}; if(typeof moment!=='function'&&moment.default) moment=moment.default return factory(moment, jquery); }); }else if(typeof module==='object'&&module.exports){ var jQuery=(typeof window!='undefined') ? window.jQuery:undefined; if(!jQuery){ jQuery=require('jquery'); if(!jQuery.fn) jQuery.fn={};} var moment=(typeof window!='undefined'&&typeof window.moment!='undefined') ? window.moment:require('moment'); module.exports=factory(moment, jQuery); }else{ root.daterangepicker=factory(root.moment, root.jQuery); }}(this, function(moment, $){ var DateRangePicker=function(element, options, cb){ this.parentEl='body'; this.element=$(element); this.startDate=moment().startOf('day'); this.endDate=moment().endOf('day'); this.minDate=false; this.minDateSpan=false; this.maxDate=false; this.maxSpan=false; this.minSpan=false; this.start_date_picked=0; this.autoApply=false; this.singleDatePicker=false; this.showDropdowns=false; this.minYear=moment().subtract(100, 'year').format('YYYY'); this.maxYear=moment().add(100, 'year').format('YYYY'); this.showWeekNumbers=false; this.showISOWeekNumbers=false; this.showCustomRangeLabel=true; this.timePicker=false; this.timePicker24Hour=false; this.timePickerIncrement=1; this.timePickerSeconds=false; this.linkedCalendars=true; this.autoUpdateInput=true; this.alwaysShowCalendars=false; this.ranges={}; this.opens='right'; if(this.element.hasClass('pull-right')) this.opens='left'; this.drops='down'; if(this.element.hasClass('dropup')) this.drops='up'; this.buttonClasses='btn btn-sm'; this.applyButtonClasses='btn-primary'; this.cancelButtonClasses='btn-default'; this.locale={ direction: 'ltr', format: moment.localeData().longDateFormat('L'), separator: ' - ', applyLabel: 'Apply', cancelLabel: 'Cancel', weekLabel: 'W', customRangeLabel: 'Custom Range', daysOfWeek: moment.weekdaysMin(), monthNames: moment.monthsShort(), firstDay: moment.localeData().firstDayOfWeek() }; this.callback=function(){ }; this.isShowing=false; this.leftCalendar={}; this.rightCalendar={}; if(typeof options!=='object'||options===null) options={}; options=$.extend(this.element.data(), options); if(typeof options.showPrice=='boolean'){ this.showPrice=options.showPrice; } if(typeof options.template!=='string'&&!(options.template instanceof $)) options.template = '
' + '
' + '
' + '
' + '
' + '
' + '
' + '
' + '
' + '
' + '
' + '' + '' + ' ' + '
' + '
'; this.parentEl=(options.parentEl&&$(options.parentEl).length) ? $(options.parentEl):$(this.parentEl); this.container=$(options.template).appendTo(this.parentEl); if(typeof options.locale==='object'){ if(typeof options.locale.direction==='string') this.locale.direction=options.locale.direction; if(typeof options.locale.format==='string') this.locale.format=options.locale.format; if(typeof options.locale.separator==='string') this.locale.separator=options.locale.separator; if(typeof options.locale.daysOfWeek==='object') this.locale.daysOfWeek=options.locale.daysOfWeek.slice(); if(typeof options.locale.monthNames==='object') this.locale.monthNames=options.locale.monthNames.slice(); if(typeof options.locale.firstDay==='number') this.locale.firstDay=options.locale.firstDay; if(typeof options.locale.applyLabel==='string') this.locale.applyLabel=options.locale.applyLabel; if(typeof options.locale.cancelLabel==='string') this.locale.cancelLabel=options.locale.cancelLabel; if(typeof options.locale.weekLabel==='string') this.locale.weekLabel=options.locale.weekLabel; if(typeof options.locale.customRangeLabel==='string'){ var elem=document.createElement('textarea'); elem.innerHTML=options.locale.customRangeLabel; var rangeHtml=elem.value; this.locale.customRangeLabel=rangeHtml; }} this.container.addClass(this.locale.direction); if(typeof options.startDate==='string') this.startDate=moment(options.startDate, this.locale.format); if(typeof options.endDate==='string') this.endDate=moment(options.endDate, this.locale.format); if(typeof options.minDate==='string') this.minDate=moment(options.minDate, this.locale.format); if(typeof options.maxDate==='string') this.maxDate=moment(options.maxDate, this.locale.format); if(typeof options.startDate==='object') this.startDate=moment(options.startDate); if(typeof options.endDate==='object') this.endDate=moment(options.endDate); if(typeof options.minDate==='object') this.minDate=moment(options.minDate); if(typeof options.maxDate==='object') this.maxDate=moment(options.maxDate); if(this.minDate&&this.startDate.isBefore(this.minDate)) this.startDate=this.minDate.clone(); if(this.maxDate&&this.endDate.isAfter(this.maxDate)) this.endDate=this.maxDate.clone(); if(typeof options.applyButtonClasses==='string') this.applyButtonClasses=options.applyButtonClasses; if(typeof options.applyClass==='string') this.applyButtonClasses=options.applyClass; if(typeof options.cancelButtonClasses==='string') this.cancelButtonClasses=options.cancelButtonClasses; if(typeof options.cancelClass==='string') this.cancelButtonClasses=options.cancelClass; if(typeof options.maxSpan==='object') this.maxSpan=options.maxSpan; if(typeof options.minSpan==='object'){ this.minSpan=options.minSpan; } if(typeof options.dateLimit==='object') this.maxSpan=options.dateLimit; if(typeof options.opens==='string') this.opens=options.opens; if(typeof options.drops==='string') this.drops=options.drops; if(typeof options.showWeekNumbers==='boolean') this.showWeekNumbers=options.showWeekNumbers; if(typeof options.showISOWeekNumbers==='boolean') this.showISOWeekNumbers=options.showISOWeekNumbers; if(typeof options.buttonClasses==='string') this.buttonClasses=options.buttonClasses; if(typeof options.buttonClasses==='object') this.buttonClasses=options.buttonClasses.join(' '); if(typeof options.showDropdowns==='boolean') this.showDropdowns=options.showDropdowns; if(typeof options.minYear==='number') this.minYear=options.minYear; if(typeof options.maxYear==='number') this.maxYear=options.maxYear; if(typeof options.showCustomRangeLabel==='boolean') this.showCustomRangeLabel=options.showCustomRangeLabel; if(typeof options.singleDatePicker==='boolean'){ this.singleDatePicker=options.singleDatePicker; if(this.singleDatePicker) this.endDate=this.startDate.clone(); } if(typeof options.timePicker==='boolean') this.timePicker=options.timePicker; if(typeof options.timePickerSeconds==='boolean') this.timePickerSeconds=options.timePickerSeconds; if(typeof options.timePickerIncrement==='number') this.timePickerIncrement=options.timePickerIncrement; if(typeof options.timePicker24Hour==='boolean') this.timePicker24Hour=options.timePicker24Hour; if(typeof options.autoApply==='boolean') this.autoApply=options.autoApply; if(typeof options.autoUpdateInput==='boolean') this.autoUpdateInput=options.autoUpdateInput; if(typeof options.linkedCalendars==='boolean') this.linkedCalendars=options.linkedCalendars; if(typeof options.isInvalidDate==='function') this.isInvalidDate=options.isInvalidDate; if(typeof options.isCustomDate==='function') this.isCustomDate=options.isCustomDate; if(typeof options.alwaysShowCalendars==='boolean') this.alwaysShowCalendars=options.alwaysShowCalendars; if(this.locale.firstDay!=0){ var iterator=this.locale.firstDay; while (iterator > 0){ this.locale.daysOfWeek.push(this.locale.daysOfWeek.shift()); iterator--; }} var start, end, range; if(typeof options.startDate==='undefined'&&typeof options.endDate==='undefined'){ if($(this.element).is(':text')){ var val=$(this.element).val(), split=val.split(this.locale.separator); start=end=null; if(split.length==2){ start=moment(split[0], this.locale.format); end=moment(split[1], this.locale.format); }else if(this.singleDatePicker&&val!==""){ start=moment(val, this.locale.format); end=moment(val, this.locale.format); } if(start!==null&&end!==null){ this.setStartDate(start); this.setEndDate(end); }} } if(typeof options.ranges==='object'){ for (range in options.ranges){ if(typeof options.ranges[range][0]==='string') start=moment(options.ranges[range][0], this.locale.format); else start=moment(options.ranges[range][0]); if(typeof options.ranges[range][1]==='string') end=moment(options.ranges[range][1], this.locale.format); else end=moment(options.ranges[range][1]); if(this.minDate&&start.isBefore(this.minDate)) start=this.minDate.clone(); var maxDate=this.maxDate; if(this.maxSpan&&maxDate&&start.clone().add(this.maxSpan).isAfter(maxDate)) maxDate=start.clone().add(this.maxSpan); if(maxDate&&end.isAfter(maxDate)) end=maxDate.clone(); if(this.minSpan){ this.minDateSpan=start.clone().add(this.minSpan); } if((this.minDate&&end.isBefore(this.minDate, this.timepicker ? 'minute':'day')) || (maxDate&&start.isAfter(maxDate, this.timepicker ? 'minute':'day'))) continue; var elem=document.createElement('textarea'); elem.innerHTML=range; var rangeHtml=elem.value; this.ranges[rangeHtml]=[start, end]; } var list=''; this.container.find('.ranges').prepend(list); } if(typeof cb==='function'){ this.callback=cb; } if(!this.timePicker){ this.startDate=this.startDate.startOf('day'); this.endDate=this.endDate.endOf('day'); this.container.find('.calendar-time').hide(); } if(this.timePicker&&this.autoApply) this.autoApply=false; if(this.autoApply){ this.container.addClass('auto-apply'); } if(typeof options.ranges==='object') this.container.addClass('show-ranges'); if(this.singleDatePicker){ this.container.addClass('single'); this.container.find('.drp-calendar.left').addClass('single'); this.container.find('.drp-calendar.left').show(); this.container.find('.drp-calendar.right').hide(); if(!this.timePicker){ this.container.addClass('auto-apply'); }} if((typeof options.ranges==='undefined'&&!this.singleDatePicker)||this.alwaysShowCalendars){ this.container.addClass('show-calendar'); } this.container.addClass('opens' + this.opens); this.container.find('.applyBtn, .cancelBtn').addClass(this.buttonClasses); if(this.applyButtonClasses.length) this.container.find('.applyBtn').addClass(this.applyButtonClasses); if(this.cancelButtonClasses.length) this.container.find('.cancelBtn').addClass(this.cancelButtonClasses); this.container.find('.applyBtn').html(this.locale.applyLabel); this.container.find('.cancelBtn').html(this.locale.cancelLabel); this.container.find('.drp-calendar') .on('click.daterangepicker', '.prev', $.proxy(this.clickPrev, this)) .on('click.daterangepicker', '.next', $.proxy(this.clickNext, this)) .on('mousedown.daterangepicker', 'td.available', $.proxy(this.clickDate, this)) .on('mouseenter.daterangepicker', 'td.available', $.proxy(this.hoverDate, this)) .on('change.daterangepicker', 'select.yearselect', $.proxy(this.monthOrYearChanged, this)) .on('change.daterangepicker', 'select.monthselect', $.proxy(this.monthOrYearChanged, this)) .on('change.daterangepicker', 'select.hourselect,select.minuteselect,select.secondselect,select.ampmselect', $.proxy(this.timeChanged, this)) this.container.find('.ranges') .on('click.daterangepicker', 'li', $.proxy(this.clickRange, this)) this.container.find('.drp-buttons') .on('click.daterangepicker', 'button.applyBtn', $.proxy(this.clickApply, this)) .on('click.daterangepicker', 'button.cancelBtn', $.proxy(this.clickCancel, this)) if(this.element.is('input')||this.element.is('button')){ this.element.on({ 'click.daterangepicker': $.proxy(this.show, this), 'focus.daterangepicker': $.proxy(this.show, this), 'keyup.daterangepicker': $.proxy(this.elementChanged, this), 'keydown.daterangepicker': $.proxy(this.keydown, this) }); }else{ this.element.on('click.daterangepicker', $.proxy(this.toggle, this)); this.element.on('keydown.daterangepicker', $.proxy(this.toggle, this)); } this.updateElement(); }; DateRangePicker.prototype={ constructor: DateRangePicker, setStartDate: function(startDate){ if(typeof startDate==='string') this.startDate=moment(startDate, this.locale.format); if(typeof startDate==='object') this.startDate=moment(startDate); if(!this.timePicker) this.startDate=this.startDate.startOf('day'); if(this.timePicker&&this.timePickerIncrement) this.startDate.minute(Math.round(this.startDate.minute() / this.timePickerIncrement) * this.timePickerIncrement); if(this.minDate&&this.startDate.isBefore(this.minDate)){ this.startDate=this.minDate.clone(); if(this.timePicker&&this.timePickerIncrement) this.startDate.minute(Math.round(this.startDate.minute() / this.timePickerIncrement) * this.timePickerIncrement); } if(this.maxDate&&this.startDate.isAfter(this.maxDate)){ this.startDate=this.maxDate.clone(); if(this.timePicker&&this.timePickerIncrement) this.startDate.minute(Math.floor(this.startDate.minute() / this.timePickerIncrement) * this.timePickerIncrement); } if(!this.isShowing) this.updateElement(); this.updateMonthsInView(); }, setEndDate: function(endDate){ if(typeof endDate==='string') this.endDate=moment(endDate, this.locale.format); if(typeof endDate==='object') this.endDate=moment(endDate); if(!this.timePicker) this.endDate=this.endDate.endOf('day'); if(this.timePicker&&this.timePickerIncrement) this.endDate.minute(Math.round(this.endDate.minute() / this.timePickerIncrement) * this.timePickerIncrement); if(this.endDate.isBefore(this.startDate)) this.endDate=this.startDate.clone(); if(this.maxDate&&this.endDate.isAfter(this.maxDate)) this.endDate=this.maxDate.clone(); if(this.maxSpan&&this.startDate.clone().add(this.maxSpan).isBefore(this.endDate)) this.endDate=this.startDate.clone().add(this.maxSpan); this.previousRightTime=this.endDate.clone(); this.container.find('.drp-selected').html(this.startDate.format(this.locale.format) + this.locale.separator + this.endDate.format(this.locale.format)); if(!this.isShowing) this.updateElement(); this.updateMonthsInView(); }, isInvalidDate: function(){ return false; }, isCustomDate: function(){ return false; }, updateView: function(){ if(this.timePicker){ this.renderTimePicker('left'); this.renderTimePicker('right'); if(!this.endDate){ this.container.find('.right .calendar-time select').prop('disabled', true).addClass('disabled'); }else{ this.container.find('.right .calendar-time select').prop('disabled', false).removeClass('disabled'); }} if(this.endDate) this.container.find('.drp-selected').html(this.startDate.format(this.locale.format) + this.locale.separator + this.endDate.format(this.locale.format)); this.updateMonthsInView(); this.updateCalendars(); this.updateFormInputs(); }, updateMonthsInView: function(){ if(this.endDate){ if(!this.singleDatePicker&&this.leftCalendar.month&&this.rightCalendar.month && (this.startDate.format('YYYY-MM')==this.leftCalendar.month.format('YYYY-MM')||this.startDate.format('YYYY-MM')==this.rightCalendar.month.format('YYYY-MM')) && (this.endDate.format('YYYY-MM')==this.leftCalendar.month.format('YYYY-MM')||this.endDate.format('YYYY-MM')==this.rightCalendar.month.format('YYYY-MM')) ){ return; } this.leftCalendar.month=this.startDate.clone().date(2); if(!this.linkedCalendars&&(this.endDate.month()!=this.startDate.month()||this.endDate.year()!=this.startDate.year())){ this.rightCalendar.month=this.endDate.clone().date(2); }else{ this.rightCalendar.month=this.startDate.clone().date(2).add(1, 'month'); }}else{ if(this.leftCalendar.month.format('YYYY-MM')!=this.startDate.format('YYYY-MM')&&this.rightCalendar.month.format('YYYY-MM')!=this.startDate.format('YYYY-MM')){ this.leftCalendar.month=this.startDate.clone().date(2); this.rightCalendar.month=this.startDate.clone().date(2).add(1, 'month'); }} if(this.maxDate&&this.linkedCalendars&&!this.singleDatePicker&&this.rightCalendar.month > this.maxDate){ this.rightCalendar.month=this.maxDate.clone().date(2); this.leftCalendar.month=this.maxDate.clone().date(2).subtract(1, 'month'); }}, updateCalendars: function(){ if(this.timePicker){ var hour, minute, second; if(this.endDate){ hour=parseInt(this.container.find('.left .hourselect').val(), 10); minute=parseInt(this.container.find('.left .minuteselect').val(), 10); if(isNaN(minute)){ minute=parseInt(this.container.find('.left .minuteselect option:last').val(), 10); } second=this.timePickerSeconds ? parseInt(this.container.find('.left .secondselect').val(), 10):0; if(!this.timePicker24Hour){ var ampm=this.container.find('.left .ampmselect').val(); if(ampm==='PM'&&hour < 12) hour +=12; if(ampm==='AM'&&hour===12) hour=0; }}else{ hour=parseInt(this.container.find('.right .hourselect').val(), 10); minute=parseInt(this.container.find('.right .minuteselect').val(), 10); if(isNaN(minute)){ minute=parseInt(this.container.find('.right .minuteselect option:last').val(), 10); } second=this.timePickerSeconds ? parseInt(this.container.find('.right .secondselect').val(), 10):0; if(!this.timePicker24Hour){ var ampm=this.container.find('.right .ampmselect').val(); if(ampm==='PM'&&hour < 12) hour +=12; if(ampm==='AM'&&hour===12) hour=0; }} this.leftCalendar.month.hour(hour).minute(minute).second(second); this.rightCalendar.month.hour(hour).minute(minute).second(second); } this.renderCalendar('left'); this.renderCalendar('right'); this.container.find('.ranges li').removeClass('active'); if(this.endDate==null) return; this.calculateChosenLabel(); }, renderCalendar: function(side){ var calendar=side=='left' ? this.leftCalendar:this.rightCalendar; var month=calendar.month.month(); var year=calendar.month.year(); var hour=calendar.month.hour(); var minute=calendar.month.minute(); var second=calendar.month.second(); var daysInMonth=moment([year, month]).daysInMonth(); var firstDay=moment([year, month, 1]); var lastDay=moment([year, month, daysInMonth]); var lastMonth=moment(firstDay).subtract(1, 'month').month(); var lastYear=moment(firstDay).subtract(1, 'month').year(); var daysInLastMonth=moment([lastYear, lastMonth]).daysInMonth(); var dayOfWeek=firstDay.day(); var calendar=[]; calendar.firstDay=firstDay; calendar.lastDay=lastDay; for (var i=0; i < 6; i++){ calendar[i]=[]; } var startDay=daysInLastMonth - dayOfWeek + this.locale.firstDay + 1; if(startDay > daysInLastMonth) startDay -=7; if(dayOfWeek==this.locale.firstDay) startDay=daysInLastMonth - 6; var curDate=moment([lastYear, lastMonth, startDay, 12, minute, second]); var col, row; for (var i=0, col=0, row=0; i < 42; i++, col++, curDate=moment(curDate).add(24, 'hour')){ if(i > 0&&col % 7===0){ col=0; row++; } calendar[row][col]=curDate.clone().hour(hour).minute(minute).second(second); curDate.hour(12); if(this.minDate&&calendar[row][col].format('YYYY-MM-DD')==this.minDate.format('YYYY-MM-DD')&&calendar[row][col].isBefore(this.minDate)&&side=='left'){ calendar[row][col]=this.minDate.clone(); } if(this.maxDate&&calendar[row][col].format('YYYY-MM-DD')==this.maxDate.format('YYYY-MM-DD')&&calendar[row][col].isAfter(this.maxDate)&&side=='right'){ calendar[row][col]=this.maxDate.clone(); }} if(side=='left'){ this.leftCalendar.calendar=calendar; }else{ this.rightCalendar.calendar=calendar; } var minDate=side=='left' ? this.minDate:this.startDate; var maxDate=this.maxDate; var selected=side=='left' ? this.startDate:this.endDate; var arrow=this.locale.direction=='ltr' ? {left: 'chevron-left', right: 'chevron-right'}:{left: 'chevron-right', right: 'chevron-left'}; var html=''; html +=''; html +=''; if(this.showWeekNumbers||this.showISOWeekNumbers) html +=''; if((!minDate||minDate.isBefore(calendar.firstDay))&&(!this.linkedCalendars||side=='left')){ html +=''; }else{ html +=''; } var dateHtml=this.locale.monthNames[calendar[1][1].month()] + calendar[1][1].format(" YYYY"); if(this.showDropdowns){ var currentMonth=calendar[1][1].month(); var currentYear=calendar[1][1].year(); var maxYear=(maxDate&&maxDate.year())||(this.maxYear); var minYear=(minDate&&minDate.year())||(this.minYear); var inMinYear=currentYear==minYear; var inMaxYear=currentYear==maxYear; var monthHtml='"; var yearHtml=''; dateHtml=monthHtml + yearHtml; } html +=''; if((!maxDate||maxDate.isAfter(calendar.lastDay))&&(!this.linkedCalendars||side=='right'||this.singleDatePicker)){ html +=''; }else{ html +=''; } html +=''; html +=''; if(this.showWeekNumbers||this.showISOWeekNumbers) html +=''; $.each(this.locale.daysOfWeek, function(index, dayOfWeek){ html +=''; }); html +=''; html +=''; html +=''; if(this.endDate==null&&this.maxSpan){ var maxLimit=this.startDate.clone().add(this.maxSpan).endOf('day'); if(!maxDate||maxLimit.isBefore(maxDate)){ maxDate=maxLimit; }} if(this.endDate==null&&this.minSpan){ var minLimit=this.startDate.clone().add(this.minSpan).endOf('day'); if(!minDate||minLimit.isAfter(minDate)){ this.minDateSpan=minLimit; }} for (var row=0; row < 6; row++){ html +=''; if(this.showWeekNumbers) html +=''; else if(this.showISOWeekNumbers) html +=''; for (var col=0; col < 7; col++){ var classes=[]; if(calendar[row][col].isSame(new Date(), "day")) classes.push('today'); if(calendar[row][col].isoWeekday() > 5) classes.push('weekend'); if(calendar[row][col].month()!=calendar[1][1].month()) classes.push('off', 'ends'); if(this.minDate&&calendar[row][col].isBefore(this.minDate, 'day')) classes.push('off', 'disabled'); if(maxDate&&calendar[row][col].isAfter(maxDate, 'day')) classes.push('off', 'disabled'); var infome=calendar[row][col].year()+"/"+(calendar[row][col].month()+1)+"/"+calendar[row][col].date(); var date_format=control_vars.date_format.toUpperCase(); var infome2=moment(infome, 'YYYY-M-DD').format(date_format); var infome_unix=moment(infome, 'YYYY-M-DD').valueOf(); if(this.element[0].id==='start_date'){ if(wpestate_booking_invalid_Date_new(infome_unix)==='is_block_check_in_check_out'){ classes.push('check_in_block','disabled'); }else if(wpestate_booking_invalid_Date_new(infome_unix)==='is_block_check_in'){ classes.push('check_in_block_is_block_check_in','disabled'); } if(this.start_date_picked===1&&calendar[row][col].isAfter(this.startDate, 'day')){ for(var i=0; i < classes.length; i++){ if(classes[i]==='check_in_block_is_block_check_in'){ classes.splice(i, 1); }} for(var i=0; i < classes.length; i++){ if(classes[i]==='disabled'){ classes.splice(i, 1); }} } if(typeof(mega_details)==='object'){ var minday_unix=moment(this.startDate).utc().add(moment(this.startDate).utcOffset(),'minutes').valueOf(); var minday_unix=minday_unix/1000; if(mega_details[minday_unix]!=undefined){ minim_days=parseFloat(mega_details[minday_unix]['period_min_days_booking'] ,10); var temp_min_span={ "days": minim_days }; var minLimit=this.startDate.clone().add(temp_min_span).endOf('day'); this.minDateSpan=minLimit; } if(this.minDateSpan&&this.startDate&&calendar[row][col].isBefore(this.minDateSpan, 'day')&&calendar[row][col].isAfter(this.startDate, 'day')){ classes.push('wpestate_min_days_required', 'disabled'); classes.push('off', 'disabled'); }} } if(this.isInvalidDate(calendar[row][col])) classes.push('off', 'disabled'); if(calendar[row][col].format('YYYY-MM-DD')==this.startDate.format('YYYY-MM-DD')) classes.push('active', 'start-date'); if(this.endDate!=null&&calendar[row][col].format('YYYY-MM-DD')==this.endDate.format('YYYY-MM-DD')) classes.push('active', 'end-date'); if(this.endDate!=null&&calendar[row][col] > this.startDate&&calendar[row][col] < this.endDate) classes.push('in-range'); var isCustom=this.isCustomDate(calendar[row][col]); if(isCustom!==false){ if(typeof isCustom==='string') classes.push(isCustom); else Array.prototype.push.apply(classes, isCustom); } var cname='', disabled=false; for (var i=0; i < classes.length; i++){ cname +=classes[i] + ' '; if(classes[i]=='disabled') disabled=true; } if(!disabled) cname +='available'; if(typeof wpestate_show_price_Daterangepicker==="function"&&this.element[0].id==='start_date'){ html +=''; }else{ html +=''; }} html +=''; } html +=''; html +='
' + dateHtml + '
' + this.locale.weekLabel + '' + dayOfWeek + '
' + calendar[row][0].week() + '' + calendar[row][0].isoWeek() + '' + calendar[row][col].date() + '
'+wpestate_show_price_Daterangepicker(infome_unix)+'
' + calendar[row][col].date() + '
'; this.container.find('.drp-calendar.' + side + ' .calendar-table').html(html); }, renderTimePicker: function(side){ if(side=='right'&&!this.endDate) return; var html, selected, minDate, maxDate=this.maxDate; if(this.maxSpan&&(!this.maxDate||this.startDate.clone().add(this.maxSpan).isBefore(this.maxDate))) maxDate=this.startDate.clone().add(this.maxSpan); if(side=='left'){ selected=this.startDate.clone(); minDate=this.minDate; }else if(side=='right'){ selected=this.endDate.clone(); minDate=this.startDate; var timeSelector=this.container.find('.drp-calendar.right .calendar-time'); if(timeSelector.html()!=''){ selected.hour(!isNaN(selected.hour()) ? selected.hour():timeSelector.find('.hourselect option:selected').val()); selected.minute(!isNaN(selected.minute()) ? selected.minute():timeSelector.find('.minuteselect option:selected').val()); selected.second(!isNaN(selected.second()) ? selected.second():timeSelector.find('.secondselect option:selected').val()); if(!this.timePicker24Hour){ var ampm=timeSelector.find('.ampmselect option:selected').val(); if(ampm==='PM'&&selected.hour() < 12) selected.hour(selected.hour() + 12); if(ampm==='AM'&&selected.hour()===12) selected.hour(0); }} if(selected.isBefore(this.startDate)) selected=this.startDate.clone(); if(maxDate&&selected.isAfter(maxDate)) selected=maxDate.clone(); } html=' '; html +=': '; if(this.timePickerSeconds){ html +=': '; } if(!this.timePicker24Hour){ html +=''; } this.container.find('.drp-calendar.' + side + ' .calendar-time').html(html); }, updateFormInputs: function(){ if(this.singleDatePicker||(this.endDate&&(this.startDate.isBefore(this.endDate)||this.startDate.isSame(this.endDate)))){ this.container.find('button.applyBtn').prop('disabled', false); }else{ this.container.find('button.applyBtn').prop('disabled', true); }}, move: function(){ var parentOffset={ top: 0, left: 0 }, containerTop; var parentRightEdge=$(window).width(); if(!this.parentEl.is('body')){ parentOffset={ top: this.parentEl.offset().top - this.parentEl.scrollTop(), left: this.parentEl.offset().left - this.parentEl.scrollLeft() }; parentRightEdge=this.parentEl[0].clientWidth + this.parentEl.offset().left; } if(this.drops=='up') containerTop=this.element.offset().top - this.container.outerHeight() - parentOffset.top; else containerTop=this.element.offset().top + this.element.outerHeight() - parentOffset.top; this.container.css({ top: 0, left: 0, right: 'auto' }); var containerWidth=this.container.outerWidth(); this.container[this.drops=='up' ? 'addClass':'removeClass']('drop-up'); if(this.opens=='left'){ var containerRight=parentRightEdge - this.element.offset().left - this.element.outerWidth(); if(containerWidth + containerRight > $(window).width()){ this.container.css({ top: containerTop, right: 'auto', left: 9 }); }else{ this.container.css({ top: containerTop, right: containerRight, left: 'auto' }); }}else if(this.opens=='center'){ var containerLeft=this.element.offset().left - parentOffset.left + this.element.outerWidth() / 2 - containerWidth / 2; if(containerLeft < 0){ this.container.css({ top: containerTop, right: 'auto', left: 9 }); }else if(containerLeft + containerWidth > $(window).width()){ this.container.css({ top: containerTop, left: 'auto', right: 0 }); }else{ this.container.css({ top: containerTop, left: containerLeft, right: 'auto' }); }}else{ var containerLeft=this.element.offset().left - parentOffset.left; if(containerLeft + containerWidth > $(window).width()){ this.container.css({ top: containerTop, left: 'auto', right: 0 }); }else{ this.container.css({ top: containerTop, left: containerLeft, right: 'auto' }); }} }, show: function(e){ if(this.isShowing) return; this._outsideClickProxy=$.proxy(function(e){ this.outsideClick(e); }, this); $(document) .on('mousedown.daterangepicker', this._outsideClickProxy) .on('touchend.daterangepicker', this._outsideClickProxy) .on('click.daterangepicker', '[data-toggle=dropdown]', this._outsideClickProxy) .on('focusin.daterangepicker', this._outsideClickProxy); $(window).on('resize.daterangepicker', $.proxy(function(e){ this.move(e); }, this)); this.oldStartDate=this.startDate.clone(); this.oldEndDate=this.endDate.clone(); this.previousRightTime=this.endDate.clone(); this.updateView(); this.container.show(); this.move(); this.element.trigger('show.daterangepicker', this); this.isShowing=true; }, hide: function(e){ if(!this.isShowing) return; if(!this.endDate){ this.startDate=this.oldStartDate.clone(); this.endDate=this.oldEndDate.clone(); } if(!this.startDate.isSame(this.oldStartDate)||!this.endDate.isSame(this.oldEndDate)) this.callback(this.startDate.clone(), this.endDate.clone(), this.chosenLabel); this.updateElement(); $(document).off('.daterangepicker'); $(window).off('.daterangepicker'); this.container.hide(); this.element.trigger('hide.daterangepicker', this); this.isShowing=false; }, toggle: function(e){ if(this.isShowing){ this.hide(); }else{ this.show(); }}, outsideClick: function(e){ var target=$(e.target); if(e.type=="focusin" || target.closest(this.element).length || target.closest(this.container).length || target.closest('.calendar-table').length ) return; this.hide(); this.element.trigger('outsideClick.daterangepicker', this); }, showCalendars: function(){ this.container.addClass('show-calendar'); this.move(); this.element.trigger('showCalendar.daterangepicker', this); }, hideCalendars: function(){ this.container.removeClass('show-calendar'); this.element.trigger('hideCalendar.daterangepicker', this); }, clickRange: function(e){ var label=e.target.getAttribute('data-range-key'); this.chosenLabel=label; if(label==this.locale.customRangeLabel){ this.showCalendars(); }else{ var dates=this.ranges[label]; this.startDate=dates[0]; this.endDate=dates[1]; if(!this.timePicker){ this.startDate.startOf('day'); this.endDate.endOf('day'); } if(!this.alwaysShowCalendars) this.hideCalendars(); this.clickApply(); }}, clickPrev: function(e){ var cal=$(e.target).parents('.drp-calendar'); if(cal.hasClass('left')){ this.leftCalendar.month.subtract(1, 'month'); if(this.linkedCalendars) this.rightCalendar.month.subtract(1, 'month'); }else{ this.rightCalendar.month.subtract(1, 'month'); } this.updateCalendars(); }, clickNext: function(e){ var cal=$(e.target).parents('.drp-calendar'); if(cal.hasClass('left')){ this.leftCalendar.month.add(1, 'month'); }else{ this.rightCalendar.month.add(1, 'month'); if(this.linkedCalendars) this.leftCalendar.month.add(1, 'month'); } this.updateCalendars(); }, hoverDate: function(e){ if(!$(e.target).hasClass('available')) return; var title=$(e.target).attr('data-title'); var row=title.substr(1, 1); var col=title.substr(3, 1); var cal=$(e.target).parents('.drp-calendar'); var date=cal.hasClass('left') ? this.leftCalendar.calendar[row][col]:this.rightCalendar.calendar[row][col]; var leftCalendar=this.leftCalendar; var rightCalendar=this.rightCalendar; var startDate=this.startDate; if(!this.endDate){ this.container.find('.drp-calendar tbody td').each(function(index, el){ if($(el).hasClass('week')) return; var title=$(el).attr('data-title'); var row=title.substr(1, 1); var col=title.substr(3, 1); var cal=$(el).parents('.drp-calendar'); var dt=cal.hasClass('left') ? leftCalendar.calendar[row][col]:rightCalendar.calendar[row][col]; if((dt.isAfter(startDate)&&dt.isBefore(date))||dt.isSame(date, 'day')){ $(el).addClass('in-range'); }else{ $(el).removeClass('in-range'); }}); }}, clickDate: function(e){ who_is=1; jQuery('.wpestate_calendar').removeClass('minim_days_reservation').removeClass('wpestate_min_days_required'); if(!$(e.target).hasClass('available')) return; var title=$(e.target).attr('data-title'); var row=title.substr(1, 1); var col=title.substr(3, 1); var cal=$(e.target).parents('.drp-calendar'); var date=cal.hasClass('left') ? this.leftCalendar.calendar[row][col]:this.rightCalendar.calendar[row][col]; if(this.endDate||date.isBefore(this.startDate, 'day')){ if(this.timePicker){ var hour=parseInt(this.container.find('.left .hourselect').val(), 10); if(!this.timePicker24Hour){ var ampm=this.container.find('.left .ampmselect').val(); if(ampm==='PM'&&hour < 12) hour +=12; if(ampm==='AM'&&hour===12) hour=0; } var minute=parseInt(this.container.find('.left .minuteselect').val(), 10); if(isNaN(minute)){ minute=parseInt(this.container.find('.left .minuteselect option:last').val(), 10); } var second=this.timePickerSeconds ? parseInt(this.container.find('.left .secondselect').val(), 10):0; date=date.clone().hour(hour).minute(minute).second(second); } this.endDate=null; this.setStartDate(date.clone()); who_is=0; var input_val=$(e.target).attr("data-custom"); this.element.val(input_val); this.start_date_picked=1; }else if(!this.endDate&&date.isBefore(this.startDate)){ this.setEndDate(this.startDate.clone()); who_is=1; }else{ if(this.timePicker){ var hour=parseInt(this.container.find('.right .hourselect').val(), 10); if(!this.timePicker24Hour){ var ampm=this.container.find('.right .ampmselect').val(); if(ampm==='PM'&&hour < 12) hour +=12; if(ampm==='AM'&&hour===12) hour=0; } var minute=parseInt(this.container.find('.right .minuteselect').val(), 10); if(isNaN(minute)){ minute=parseInt(this.container.find('.right .minuteselect option:last').val(), 10); } var second=this.timePickerSeconds ? parseInt(this.container.find('.right .secondselect').val(), 10):0; date=date.clone().hour(hour).minute(minute).second(second); } this.setEndDate(date.clone()); if(this.autoApply){ this.calculateChosenLabel(); this.clickApply(); } this.start_date_picked=0; } if(this.singleDatePicker){ this.setEndDate(this.startDate); if(!this.timePicker) this.clickApply(); } this.updateView(); e.stopPropagation(); }, calculateChosenLabel: function (){ var customRange=true; var i=0; for (var range in this.ranges){ if(this.timePicker){ var format=this.timePickerSeconds ? "YYYY-MM-DD HH:mm:ss":"YYYY-MM-DD HH:mm"; if(this.startDate.format(format)==this.ranges[range][0].format(format)&&this.endDate.format(format)==this.ranges[range][1].format(format)){ customRange=false; this.chosenLabel=this.container.find('.ranges li:eq(' + i + ')').addClass('active').attr('data-range-key'); break; }}else{ if(this.startDate.format('YYYY-MM-DD')==this.ranges[range][0].format('YYYY-MM-DD')&&this.endDate.format('YYYY-MM-DD')==this.ranges[range][1].format('YYYY-MM-DD')){ customRange=false; this.chosenLabel=this.container.find('.ranges li:eq(' + i + ')').addClass('active').attr('data-range-key'); break; }} i++; } if(customRange){ if(this.showCustomRangeLabel){ this.chosenLabel=this.container.find('.ranges li:last').addClass('active').attr('data-range-key'); }else{ this.chosenLabel=null; } this.showCalendars(); }}, clickApply: function(e){ this.hide(); this.element.trigger('apply.daterangepicker', this); }, clickCancel: function(e){ this.startDate=this.oldStartDate; this.endDate=this.oldEndDate; this.hide(); this.element.trigger('cancel.daterangepicker', this); }, monthOrYearChanged: function(e){ var isLeft=$(e.target).closest('.drp-calendar').hasClass('left'), leftOrRight=isLeft ? 'left':'right', cal=this.container.find('.drp-calendar.'+leftOrRight); var month=parseInt(cal.find('.monthselect').val(), 10); var year=cal.find('.yearselect').val(); if(!isLeft){ if(year < this.startDate.year()||(year==this.startDate.year()&&month < this.startDate.month())){ month=this.startDate.month(); year=this.startDate.year(); }} if(this.minDate){ if(year < this.minDate.year()||(year==this.minDate.year()&&month < this.minDate.month())){ month=this.minDate.month(); year=this.minDate.year(); }} if(this.maxDate){ if(year > this.maxDate.year()||(year==this.maxDate.year()&&month > this.maxDate.month())){ month=this.maxDate.month(); year=this.maxDate.year(); }} if(isLeft){ this.leftCalendar.month.month(month).year(year); if(this.linkedCalendars) this.rightCalendar.month=this.leftCalendar.month.clone().add(1, 'month'); }else{ this.rightCalendar.month.month(month).year(year); if(this.linkedCalendars) this.leftCalendar.month=this.rightCalendar.month.clone().subtract(1, 'month'); } this.updateCalendars(); }, timeChanged: function(e){ var cal=$(e.target).closest('.drp-calendar'), isLeft=cal.hasClass('left'); var hour=parseInt(cal.find('.hourselect').val(), 10); var minute=parseInt(cal.find('.minuteselect').val(), 10); if(isNaN(minute)){ minute=parseInt(cal.find('.minuteselect option:last').val(), 10); } var second=this.timePickerSeconds ? parseInt(cal.find('.secondselect').val(), 10):0; if(!this.timePicker24Hour){ var ampm=cal.find('.ampmselect').val(); if(ampm==='PM'&&hour < 12) hour +=12; if(ampm==='AM'&&hour===12) hour=0; } if(isLeft){ var start=this.startDate.clone(); start.hour(hour); start.minute(minute); start.second(second); this.setStartDate(start); if(this.singleDatePicker){ this.endDate=this.startDate.clone(); }else if(this.endDate&&this.endDate.format('YYYY-MM-DD')==start.format('YYYY-MM-DD')&&this.endDate.isBefore(start)){ this.setEndDate(start.clone()); }}else if(this.endDate){ var end=this.endDate.clone(); end.hour(hour); end.minute(minute); end.second(second); this.setEndDate(end); } this.updateCalendars(); this.updateFormInputs(); this.renderTimePicker('left'); this.renderTimePicker('right'); }, elementChanged: function(){ if(!this.element.is('input')) return; if(!this.element.val().length) return; var dateString=this.element.val().split(this.locale.separator), start=null, end=null; if(dateString.length===2){ start=moment(dateString[0], this.locale.format); end=moment(dateString[1], this.locale.format); } if(this.singleDatePicker||start===null||end===null){ start=moment(this.element.val(), this.locale.format); end=start; } if(!start.isValid()||!end.isValid()) return; this.setStartDate(start); this.setEndDate(end); this.updateView(); }, keydown: function(e){ if((e.keyCode===9)||(e.keyCode===13)){ this.hide(); } if(e.keyCode===27){ e.preventDefault(); e.stopPropagation(); this.hide(); }}, updateElement: function(){ if(this.element.is('input')&&this.autoUpdateInput){ var newValue=this.startDate.format(this.locale.format); if(!this.singleDatePicker){ newValue +=this.locale.separator + this.endDate.format(this.locale.format); } if(newValue!==this.element.val()){ this.element.val(newValue).trigger('change'); }} }, remove: function(){ this.container.remove(); this.element.off('.daterangepicker'); this.element.removeData(); }}; $.fn.daterangepicker=function(options, callback){ var implementOptions=$.extend(true, {}, $.fn.daterangepicker.defaultOptions, options); this.each(function(){ var el=$(this); if(el.data('daterangepicker')) el.data('daterangepicker').remove(); el.data('daterangepicker', new DateRangePicker(el, implementOptions, callback)); }); return this; }; return DateRangePicker; })); (function(factory){ if(typeof define==="function"&&define.amd){ define([ "../datepicker" ], factory); }else{ factory(jQuery.datepicker); }}(function(datepicker){ datepicker.regional['en-GB']={ closeText: 'Done', prevText: 'Prev', nextText: 'Next', currentText: 'Today', monthNames: ['January','February','March','April','May','June', 'July','August','September','October','November','December'], monthNamesShort: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], dayNames: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'], dayNamesShort: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'], dayNamesMin: ['Su','Mo','Tu','We','Th','Fr','Sa'], weekHeader: 'Wk', dateFormat: 'dd/mm/yy', firstDay: 1, isRTL: false, showMonthAfterYear: false, yearSuffix: ''}; datepicker.setDefaults(datepicker.regional['en-GB']); return datepicker.regional['en-GB']; })); function InfoBox(opt_opts){ opt_opts=opt_opts||{}; google.maps.OverlayView.apply(this, arguments); this.content_=opt_opts.content||""; this.disableAutoPan_=opt_opts.disableAutoPan||false; this.maxWidth_=opt_opts.maxWidth||0; this.pixelOffset_=opt_opts.pixelOffset||new google.maps.Size(0, 0); this.position_=opt_opts.position||new google.maps.LatLng(0, 0); this.zIndex_=opt_opts.zIndex||null; this.boxClass_=opt_opts.boxClass||"infoBox"; this.boxStyle_=opt_opts.boxStyle||{}; this.closeBoxMargin_=opt_opts.closeBoxMargin||"2px"; this.closeBoxURL_=opt_opts.closeBoxURL||"http://www.google.com/intl/en_us/mapfiles/close.gif"; if(opt_opts.closeBoxURL===""){ this.closeBoxURL_=""; } this.infoBoxClearance_=opt_opts.infoBoxClearance||new google.maps.Size(1, 1); this.isHidden_=opt_opts.isHidden||false; this.alignBottom_=opt_opts.alignBottom||false; this.pane_=opt_opts.pane||"floatPane"; this.enableEventPropagation_=opt_opts.enableEventPropagation||false; this.div_=null; this.closeListener_=null; this.eventListener1_=null; this.eventListener2_=null; this.eventListener3_=null; this.moveListener_=null; this.contextListener_=null; this.fixedWidthSet_=null; } InfoBox.prototype=new google.maps.OverlayView(); InfoBox.prototype.createInfoBoxDiv_=function (){ var bw; var me=this; var cancelHandler=function (e){ e.cancelBubble=true; if(e.stopPropagation){ e.stopPropagation(); }}; var ignoreHandler=function (e){ e.returnValue=false; if(e.preventDefault){ e.preventDefault(); } if(!me.enableEventPropagation_){ cancelHandler(e); }}; if(!this.div_){ this.div_=document.createElement("div"); this.setBoxStyle_(); if(typeof this.content_.nodeType==="undefined"){ this.div_.innerHTML=this.getCloseBoxImg_() + this.content_; }else{ this.div_.innerHTML=this.getCloseBoxImg_(); this.div_.appendChild(this.content_); } this.getPanes()[this.pane_].appendChild(this.div_); this.addClickHandler_(); if(this.div_.style.width){ this.fixedWidthSet_=true; }else{ if(this.maxWidth_!==0&&this.div_.offsetWidth > this.maxWidth_){ this.div_.style.width=this.maxWidth_; this.div_.style.overflow="auto"; this.fixedWidthSet_=true; }else{ bw=this.getBoxWidths_(); this.div_.style.width=(this.div_.offsetWidth - bw.left - bw.right) + "px"; this.fixedWidthSet_=false; }} this.panBox_(this.disableAutoPan_); if(!this.enableEventPropagation_){ this.eventListener1_=google.maps.event.addDomListener(this.div_, "mousedown", cancelHandler); this.eventListener2_=google.maps.event.addDomListener(this.div_, "click", cancelHandler); this.eventListener3_=google.maps.event.addDomListener(this.div_, "dblclick", cancelHandler); } this.contextListener_=google.maps.event.addDomListener(this.div_, "contextmenu", ignoreHandler); google.maps.event.trigger(this, "domready"); }}; InfoBox.prototype.getCloseBoxImg_=function (){ var img=""; if(this.closeBoxURL_!==""){ img=" mapWidth){ xOffset=pixPosition.x + iwWidth + iwOffsetX + padX - mapWidth; } if(this.alignBottom_){ if(pixPosition.y < (-iwOffsetY + padY + iwHeight)){ yOffset=pixPosition.y + iwOffsetY - padY - iwHeight; }else if((pixPosition.y + iwOffsetY + padY) > mapHeight){ yOffset=pixPosition.y + iwOffsetY + padY - mapHeight; }}else{ if(pixPosition.y < (-iwOffsetY + padY)){ yOffset=pixPosition.y + iwOffsetY - padY; }else if((pixPosition.y + iwHeight + iwOffsetY + padY) > mapHeight){ yOffset=pixPosition.y + iwHeight + iwOffsetY + padY - mapHeight; }} if(!(xOffset===0&&yOffset===0)){ var c=map.getCenter(); map.panBy(xOffset, yOffset); }} }}; InfoBox.prototype.setBoxStyle_=function (){ var i, boxStyle; if(this.div_){ this.div_.className=this.boxClass_; this.div_.style.cssText=""; boxStyle=this.boxStyle_; for (i in boxStyle){ if(boxStyle.hasOwnProperty(i)){ this.div_.style[i]=boxStyle[i]; }} if(typeof this.div_.style.opacity!=="undefined"&&this.div_.style.opacity!==""){ this.div_.style.filter="alpha(opacity=" + (this.div_.style.opacity * 100) + ")"; } this.div_.style.position="absolute"; this.div_.style.visibility='hidden'; if(this.zIndex_!==null){ this.div_.style.zIndex=this.zIndex_; }} }; InfoBox.prototype.getBoxWidths_=function (){ var computedStyle; var bw={top: 0, bottom: 0, left: 0, right: 0}; var box=this.div_; if(document.defaultView&&document.defaultView.getComputedStyle){ computedStyle=box.ownerDocument.defaultView.getComputedStyle(box, ""); if(computedStyle){ bw.top=parseInt(computedStyle.borderTopWidth, 10)||0; bw.bottom=parseInt(computedStyle.borderBottomWidth, 10)||0; bw.left=parseInt(computedStyle.borderLeftWidth, 10)||0; bw.right=parseInt(computedStyle.borderRightWidth, 10)||0; }}else if(document.documentElement.currentStyle){ if(box.currentStyle){ bw.top=parseInt(box.currentStyle.borderTopWidth, 10)||0; bw.bottom=parseInt(box.currentStyle.borderBottomWidth, 10)||0; bw.left=parseInt(box.currentStyle.borderLeftWidth, 10)||0; bw.right=parseInt(box.currentStyle.borderRightWidth, 10)||0; }} return bw; }; InfoBox.prototype.onRemove=function (){ if(this.div_){ this.div_.parentNode.removeChild(this.div_); this.div_=null; }}; InfoBox.prototype.draw=function (){ this.createInfoBoxDiv_(); var pixPosition=this.getProjection().fromLatLngToDivPixel(this.position_); this.div_.style.left=(pixPosition.x + this.pixelOffset_.width) + "px"; if(this.alignBottom_){ this.div_.style.bottom=-(pixPosition.y + this.pixelOffset_.height) + "px"; }else{ this.div_.style.top=(pixPosition.y + this.pixelOffset_.height) + "px"; } if(this.isHidden_){ this.div_.style.visibility='hidden'; }else{ this.div_.style.visibility="visible"; }}; InfoBox.prototype.setOptions=function (opt_opts){ if(typeof opt_opts.boxClass!=="undefined"){ this.boxClass_=opt_opts.boxClass; this.setBoxStyle_(); } if(typeof opt_opts.boxStyle!=="undefined"){ this.boxStyle_=opt_opts.boxStyle; this.setBoxStyle_(); } if(typeof opt_opts.content!=="undefined"){ this.setContent(opt_opts.content); } if(typeof opt_opts.disableAutoPan!=="undefined"){ this.disableAutoPan_=opt_opts.disableAutoPan; } if(typeof opt_opts.maxWidth!=="undefined"){ this.maxWidth_=opt_opts.maxWidth; } if(typeof opt_opts.pixelOffset!=="undefined"){ this.pixelOffset_=opt_opts.pixelOffset; } if(typeof opt_opts.position!=="undefined"){ this.setPosition(opt_opts.position); } if(typeof opt_opts.zIndex!=="undefined"){ this.setZIndex(opt_opts.zIndex); } if(typeof opt_opts.closeBoxMargin!=="undefined"){ this.closeBoxMargin_=opt_opts.closeBoxMargin; } if(typeof opt_opts.closeBoxURL!=="undefined"){ this.closeBoxURL_=opt_opts.closeBoxURL; } if(typeof opt_opts.infoBoxClearance!=="undefined"){ this.infoBoxClearance_=opt_opts.infoBoxClearance; } if(typeof opt_opts.isHidden!=="undefined"){ this.isHidden_=opt_opts.isHidden; } if(typeof opt_opts.enableEventPropagation!=="undefined"){ this.enableEventPropagation_=opt_opts.enableEventPropagation; } if(this.div_){ this.draw(); }}; InfoBox.prototype.setContent=function (content){ this.content_=content; if(this.div_){ if(this.closeListener_){ google.maps.event.removeListener(this.closeListener_); this.closeListener_=null; } if(!this.fixedWidthSet_){ this.div_.style.width=""; } if(typeof content.nodeType==="undefined"){ this.div_.innerHTML=this.getCloseBoxImg_() + content; }else{ this.div_.innerHTML=this.getCloseBoxImg_(); this.div_.appendChild(content); } if(!this.fixedWidthSet_){ this.div_.style.width=this.div_.offsetWidth + "px"; this.div_.innerHTML=this.getCloseBoxImg_() + content; } this.addClickHandler_(); } google.maps.event.trigger(this, "content_changed"); }; InfoBox.prototype.setPosition=function (latlng){ this.position_=latlng; if(this.div_){ this.draw(); } google.maps.event.trigger(this, "position_changed"); }; InfoBox.prototype.setZIndex=function (index){ this.zIndex_=index; if(this.div_){ this.div_.style.zIndex=index; } google.maps.event.trigger(this, "zindex_changed"); }; InfoBox.prototype.getContent=function (){ return this.content_; }; InfoBox.prototype.getPosition=function (){ return this.position_; }; InfoBox.prototype.getZIndex=function (){ return this.zIndex_; }; InfoBox.prototype.show=function (){ this.isHidden_=false; if(this.div_){ this.div_.style.visibility="visible"; }}; InfoBox.prototype.hide=function (){ this.isHidden_=true; if(this.div_){ this.div_.style.visibility="hidden"; }}; InfoBox.prototype.open=function (map, anchor){ var me=this; if(anchor){ this.position_=anchor.getPosition(); this.moveListener_=google.maps.event.addListener(anchor, "position_changed", function (){ me.setPosition(this.getPosition()); }); } this.setMap(map); if(this.div_){ this.panBox_(); }}; InfoBox.prototype.close=function (){ if(this.closeListener_){ google.maps.event.removeListener(this.closeListener_); this.closeListener_=null; } if(this.eventListener1_){ google.maps.event.removeListener(this.eventListener1_); google.maps.event.removeListener(this.eventListener2_); google.maps.event.removeListener(this.eventListener3_); this.eventListener1_=null; this.eventListener2_=null; this.eventListener3_=null; } if(this.moveListener_){ google.maps.event.removeListener(this.moveListener_); this.moveListener_=null; } if(this.contextListener_){ google.maps.event.removeListener(this.contextListener_); this.contextListener_=null; } this.setMap(null); }; function ClusterIcon(cluster, styles){ cluster.getMarkerClusterer().extend(ClusterIcon, google.maps.OverlayView); this.cluster_=cluster; this.className_=cluster.getMarkerClusterer().getClusterClass(); this.styles_=styles; this.center_=null; this.div_=null; this.sums_=null; this.visible_=false; this.setMap(cluster.getMap()); } ClusterIcon.prototype.onAdd=function (){ var cClusterIcon=this; var cMouseDownInCluster; var cDraggingMapByCluster; this.div_=document.createElement("div"); this.div_.className=this.className_; if(this.visible_){ this.show(); } this.getPanes().overlayMouseTarget.appendChild(this.div_); this.boundsChangedListener_=google.maps.event.addListener(this.getMap(), "bounds_changed", function (){ cDraggingMapByCluster=cMouseDownInCluster; }); google.maps.event.addDomListener(this.div_, "mousedown", function (){ cMouseDownInCluster=true; cDraggingMapByCluster=false; }); google.maps.event.addDomListener(this.div_, "click", function (e){ cMouseDownInCluster=false; if(!cDraggingMapByCluster){ var theBounds; var mz; var mc=cClusterIcon.cluster_.getMarkerClusterer(); google.maps.event.trigger(mc, "click", cClusterIcon.cluster_); google.maps.event.trigger(mc, "clusterclick", cClusterIcon.cluster_); if(mc.getZoomOnClick()){ mz=mc.getMaxZoom(); theBounds=cClusterIcon.cluster_.getBounds(); mc.getMap().fitBounds(theBounds); setTimeout(function (){ mc.getMap().fitBounds(theBounds); if(mz!==null&&(mc.getMap().getZoom() > mz)){ mc.getMap().setZoom(mz + 1); }}, 100); } e.cancelBubble=true; if(e.stopPropagation){ e.stopPropagation(); }} }); google.maps.event.addDomListener(this.div_, "mouseover", function (){ var mc=cClusterIcon.cluster_.getMarkerClusterer(); google.maps.event.trigger(mc, "mouseover", cClusterIcon.cluster_); }); google.maps.event.addDomListener(this.div_, "mouseout", function (){ var mc=cClusterIcon.cluster_.getMarkerClusterer(); google.maps.event.trigger(mc, "mouseout", cClusterIcon.cluster_); }); }; ClusterIcon.prototype.onRemove=function (){ if(this.div_&&this.div_.parentNode){ this.hide(); google.maps.event.removeListener(this.boundsChangedListener_); google.maps.event.clearInstanceListeners(this.div_); this.div_.parentNode.removeChild(this.div_); this.div_=null; }}; ClusterIcon.prototype.draw=function (){ if(this.visible_){ var pos=this.getPosFromLatLng_(this.center_); this.div_.style.top=pos.y + "px"; this.div_.style.left=pos.x + "px"; }}; ClusterIcon.prototype.hide=function (){ if(this.div_){ this.div_.style.display="none"; } this.visible_=false; }; ClusterIcon.prototype.show=function (){ if(this.div_){ var img=""; var bp=this.backgroundPosition_.split(" "); var spriteH=parseInt(bp[0].trim(), 10); var spriteV=parseInt(bp[1].trim(), 10); var pos=this.getPosFromLatLng_(this.center_); this.div_.style.cssText=this.createCss(pos); img=""; this.div_.innerHTML=img + "
" + this.sums_.text + "
"; if(typeof this.sums_.title==="undefined"||this.sums_.title===""){ this.div_.title=this.cluster_.getMarkerClusterer().getTitle(); }else{ this.div_.title=this.sums_.title; } this.div_.style.display=""; } this.visible_=true; }; ClusterIcon.prototype.useStyle=function (sums){ this.sums_=sums; var index=Math.max(0, sums.index - 1); index=Math.min(this.styles_.length - 1, index); var style=this.styles_[index]; this.url_=style.url; this.height_=style.height; this.width_=style.width; this.anchorText_=style.anchorText||[0, 0]; this.anchorIcon_=style.anchorIcon||[parseInt(this.height_ / 2, 10), parseInt(this.width_ / 2, 10)]; this.textColor_=style.textColor||"black"; this.textSize_=style.textSize||11; this.textDecoration_=style.textDecoration||"none"; this.fontWeight_=style.fontWeight||"bold"; this.fontStyle_=style.fontStyle||"normal"; this.fontFamily_=style.fontFamily||"Arial,sans-serif"; this.backgroundPosition_=style.backgroundPosition||"0 0"; }; ClusterIcon.prototype.setCenter=function (center){ this.center_=center; }; ClusterIcon.prototype.createCss=function (pos){ var style=[]; style.push("cursor: pointer;"); style.push("position: absolute; top: " + pos.y + "px; left: " + pos.x + "px;"); style.push("width: " + this.width_ + "px; height: " + this.height_ + "px;"); return style.join(""); }; ClusterIcon.prototype.getPosFromLatLng_=function (latlng){ var pos=this.getProjection().fromLatLngToDivPixel(latlng); pos.x -=this.anchorIcon_[1]; pos.y -=this.anchorIcon_[0]; pos.x=parseInt(pos.x, 10); pos.y=parseInt(pos.y, 10); return pos; }; function Cluster(mc){ this.markerClusterer_=mc; this.map_=mc.getMap(); this.gridSize_=mc.getGridSize(); this.minClusterSize_=mc.getMinimumClusterSize(); this.averageCenter_=mc.getAverageCenter(); this.markers_=[]; this.center_=null; this.bounds_=null; this.clusterIcon_=new ClusterIcon(this, mc.getStyles()); } Cluster.prototype.getSize=function (){ return this.markers_.length; }; Cluster.prototype.getMarkers=function (){ return this.markers_; }; Cluster.prototype.getCenter=function (){ return this.center_; }; Cluster.prototype.getMap=function (){ return this.map_; }; Cluster.prototype.getMarkerClusterer=function (){ return this.markerClusterer_; }; Cluster.prototype.getBounds=function (){ var i; var bounds=new google.maps.LatLngBounds(this.center_, this.center_); var markers=this.getMarkers(); for (i=0; i < markers.length; i++){ bounds.extend(markers[i].getPosition()); } return bounds; }; Cluster.prototype.remove=function (){ this.clusterIcon_.setMap(null); this.markers_=[]; delete this.markers_; }; Cluster.prototype.addMarker=function (marker){ var i; var mCount; var mz; if(this.isMarkerAlreadyAdded_(marker)){ return false; } if(!this.center_){ this.center_=marker.getPosition(); this.calculateBounds_(); }else{ if(this.averageCenter_){ var l=this.markers_.length + 1; var lat=(this.center_.lat() * (l - 1) + marker.getPosition().lat()) / l; var lng=(this.center_.lng() * (l - 1) + marker.getPosition().lng()) / l; this.center_=new google.maps.LatLng(lat, lng); this.calculateBounds_(); }} marker.isAdded=true; this.markers_.push(marker); mCount=this.markers_.length; mz=this.markerClusterer_.getMaxZoom(); if(mz!==null&&this.map_.getZoom() > mz){ if(marker.getMap()!==this.map_){ marker.setMap(this.map_); }}else if(mCount < this.minClusterSize_){ if(marker.getMap()!==this.map_){ marker.setMap(this.map_); }}else if(mCount===this.minClusterSize_){ for (i=0; i < mCount; i++){ this.markers_[i].setMap(null); }}else{ marker.setMap(null); } this.updateIcon_(); return true; }; Cluster.prototype.isMarkerInClusterBounds=function (marker){ return this.bounds_.contains(marker.getPosition()); }; Cluster.prototype.calculateBounds_=function (){ var bounds=new google.maps.LatLngBounds(this.center_, this.center_); this.bounds_=this.markerClusterer_.getExtendedBounds(bounds); }; Cluster.prototype.updateIcon_=function (){ var mCount=this.markers_.length; var mz=this.markerClusterer_.getMaxZoom(); if(mz!==null&&this.map_.getZoom() > mz){ this.clusterIcon_.hide(); return; } if(mCount < this.minClusterSize_){ this.clusterIcon_.hide(); return; } var numStyles=this.markerClusterer_.getStyles().length; var sums=this.markerClusterer_.getCalculator()(this.markers_, numStyles); this.clusterIcon_.setCenter(this.center_); this.clusterIcon_.useStyle(sums); this.clusterIcon_.show(); }; Cluster.prototype.isMarkerAlreadyAdded_=function (marker){ var i; if(this.markers_.indexOf){ return this.markers_.indexOf(marker)!==-1; }else{ for (i=0; i < this.markers_.length; i++){ if(marker===this.markers_[i]){ return true; }} } return false; }; function MarkerClusterer(map, opt_markers, opt_options){ this.extend(MarkerClusterer, google.maps.OverlayView); opt_markers=opt_markers||[]; opt_options=opt_options||{}; this.markers_=[]; this.clusters_=[]; this.listeners_=[]; this.activeMap_=null; this.ready_=false; this.gridSize_=opt_options.gridSize||60; this.minClusterSize_=opt_options.minimumClusterSize||2; this.maxZoom_=opt_options.maxZoom||null; this.styles_=opt_options.styles||[]; this.title_=opt_options.title||""; this.zoomOnClick_=true; if(opt_options.zoomOnClick!==undefined){ this.zoomOnClick_=opt_options.zoomOnClick; } this.averageCenter_=false; if(opt_options.averageCenter!==undefined){ this.averageCenter_=opt_options.averageCenter; } this.ignoreHidden_=false; if(opt_options.ignoreHidden!==undefined){ this.ignoreHidden_=opt_options.ignoreHidden; } this.enableRetinaIcons_=false; if(opt_options.enableRetinaIcons!==undefined){ this.enableRetinaIcons_=opt_options.enableRetinaIcons; } this.imagePath_=opt_options.imagePath||MarkerClusterer.IMAGE_PATH; this.imageExtension_=opt_options.imageExtension||MarkerClusterer.IMAGE_EXTENSION; this.imageSizes_=opt_options.imageSizes||MarkerClusterer.IMAGE_SIZES; this.calculator_=opt_options.calculator||MarkerClusterer.CALCULATOR; this.batchSize_=opt_options.batchSize||MarkerClusterer.BATCH_SIZE; this.batchSizeIE_=opt_options.batchSizeIE||MarkerClusterer.BATCH_SIZE_IE; this.clusterClass_=opt_options.clusterClass||"cluster"; if(navigator.userAgent.toLowerCase().indexOf("msie")!==-1){ this.batchSize_=this.batchSizeIE_; } this.setupStyles_(); this.addMarkers(opt_markers, true); this.setMap(map); } MarkerClusterer.prototype.onAdd=function (){ var cMarkerClusterer=this; this.activeMap_=this.getMap(); this.ready_=true; this.repaint(); this.listeners_=[ google.maps.event.addListener(this.getMap(), "zoom_changed", function (){ cMarkerClusterer.resetViewport_(false); if(this.getZoom()===(this.get("minZoom")||0)||this.getZoom()===this.get("maxZoom")){ google.maps.event.trigger(this, "idle"); }}), google.maps.event.addListener(this.getMap(), "idle", function (){ cMarkerClusterer.redraw_(); }) ]; }; MarkerClusterer.prototype.onRemove=function (){ var i; for (i=0; i < this.markers_.length; i++){ if(this.markers_[i].getMap()!==this.activeMap_){ this.markers_[i].setMap(this.activeMap_); }} for (i=0; i < this.clusters_.length; i++){ this.clusters_[i].remove(); } this.clusters_=[]; for (i=0; i < this.listeners_.length; i++){ google.maps.event.removeListener(this.listeners_[i]); } this.listeners_=[]; this.activeMap_=null; this.ready_=false; }; MarkerClusterer.prototype.draw=function (){}; MarkerClusterer.prototype.setupStyles_=function (){ var i, size; if(this.styles_.length > 0){ return; } for (i=0; i < this.imageSizes_.length; i++){ size=this.imageSizes_[i]; this.styles_.push({ url: this.imagePath_ + (i + 1) + "." + this.imageExtension_, height: size, width: size }); }}; MarkerClusterer.prototype.fitMapToMarkers=function (){ var i; var markers=this.getMarkers(); var bounds=new google.maps.LatLngBounds(); for (i=0; i < markers.length; i++){ bounds.extend(markers[i].getPosition()); } this.getMap().fitBounds(bounds); }; MarkerClusterer.prototype.getGridSize=function (){ return this.gridSize_; }; MarkerClusterer.prototype.setGridSize=function (gridSize){ this.gridSize_=gridSize; }; MarkerClusterer.prototype.getMinimumClusterSize=function (){ return this.minClusterSize_; }; MarkerClusterer.prototype.setMinimumClusterSize=function (minimumClusterSize){ this.minClusterSize_=minimumClusterSize; }; MarkerClusterer.prototype.getMaxZoom=function (){ return this.maxZoom_; }; MarkerClusterer.prototype.setMaxZoom=function (maxZoom){ this.maxZoom_=maxZoom; }; MarkerClusterer.prototype.getStyles=function (){ return this.styles_; }; MarkerClusterer.prototype.setStyles=function (styles){ this.styles_=styles; }; MarkerClusterer.prototype.getTitle=function (){ return this.title_; }; MarkerClusterer.prototype.setTitle=function (title){ this.title_=title; }; MarkerClusterer.prototype.getZoomOnClick=function (){ return this.zoomOnClick_; }; MarkerClusterer.prototype.setZoomOnClick=function (zoomOnClick){ this.zoomOnClick_=zoomOnClick; }; MarkerClusterer.prototype.getAverageCenter=function (){ return this.averageCenter_; }; MarkerClusterer.prototype.setAverageCenter=function (averageCenter){ this.averageCenter_=averageCenter; }; MarkerClusterer.prototype.getIgnoreHidden=function (){ return this.ignoreHidden_; }; MarkerClusterer.prototype.setIgnoreHidden=function (ignoreHidden){ this.ignoreHidden_=ignoreHidden; }; MarkerClusterer.prototype.getEnableRetinaIcons=function (){ return this.enableRetinaIcons_; }; MarkerClusterer.prototype.setEnableRetinaIcons=function (enableRetinaIcons){ this.enableRetinaIcons_=enableRetinaIcons; }; MarkerClusterer.prototype.getImageExtension=function (){ return this.imageExtension_; }; MarkerClusterer.prototype.setImageExtension=function (imageExtension){ this.imageExtension_=imageExtension; }; MarkerClusterer.prototype.getImagePath=function (){ return this.imagePath_; }; MarkerClusterer.prototype.setImagePath=function (imagePath){ this.imagePath_=imagePath; }; MarkerClusterer.prototype.getImageSizes=function (){ return this.imageSizes_; }; MarkerClusterer.prototype.setImageSizes=function (imageSizes){ this.imageSizes_=imageSizes; }; MarkerClusterer.prototype.getCalculator=function (){ return this.calculator_; }; /** * Sets the value of the calculator property. * * @param {function(Array., number)} calculator The value * of the calculator property. */ MarkerClusterer.prototype.setCalculator=function (calculator){ this.calculator_=calculator; }; MarkerClusterer.prototype.getBatchSizeIE=function (){ return this.batchSizeIE_; }; MarkerClusterer.prototype.setBatchSizeIE=function (batchSizeIE){ this.batchSizeIE_=batchSizeIE; }; MarkerClusterer.prototype.getClusterClass=function (){ return this.clusterClass_; }; MarkerClusterer.prototype.setClusterClass=function (clusterClass){ this.clusterClass_=clusterClass; }; MarkerClusterer.prototype.getMarkers=function (){ return this.markers_; }; MarkerClusterer.prototype.getTotalMarkers=function (){ return this.markers_.length; }; MarkerClusterer.prototype.getClusters=function (){ return this.clusters_; }; MarkerClusterer.prototype.getTotalClusters=function (){ return this.clusters_.length; }; MarkerClusterer.prototype.addMarker=function (marker, opt_nodraw){ this.pushMarkerTo_(marker); if(!opt_nodraw){ this.redraw_(); }}; MarkerClusterer.prototype.addMarkers=function (markers, opt_nodraw){ var key; for (key in markers){ if(markers.hasOwnProperty(key)){ this.pushMarkerTo_(markers[key]); }} if(!opt_nodraw){ this.redraw_(); }}; MarkerClusterer.prototype.pushMarkerTo_=function (marker){ if(marker.getDraggable()){ var cMarkerClusterer=this; google.maps.event.addListener(marker, "dragend", function (){ if(cMarkerClusterer.ready_){ this.isAdded=false; cMarkerClusterer.repaint(); }}); } marker.isAdded=false; this.markers_.push(marker); }; MarkerClusterer.prototype.removeMarker=function (marker, opt_nodraw){ var removed=this.removeMarker_(marker); if(!opt_nodraw&&removed){ this.repaint(); } return removed; }; MarkerClusterer.prototype.removeMarkers=function (markers, opt_nodraw){ var i, r; var removed=false; for (i=0; i < markers.length; i++){ r=this.removeMarker_(markers[i]); removed=removed||r; } if(!opt_nodraw&&removed){ this.repaint(); } return removed; }; MarkerClusterer.prototype.removeMarker_=function (marker){ var i; var index=-1; if(this.markers_.indexOf){ index=this.markers_.indexOf(marker); }else{ for (i=0; i < this.markers_.length; i++){ if(marker===this.markers_[i]){ index=i; break; }} } if(index===-1){ return false; } marker.setMap(null); this.markers_.splice(index, 1); return true; }; MarkerClusterer.prototype.clearMarkers=function (){ this.resetViewport_(true); this.markers_=[]; }; MarkerClusterer.prototype.repaint=function (){ var oldClusters=this.clusters_.slice(); this.clusters_=[]; this.resetViewport_(false); this.redraw_(); setTimeout(function (){ var i; for (i=0; i < oldClusters.length; i++){ oldClusters[i].remove(); }}, 0); }; MarkerClusterer.prototype.getExtendedBounds=function (bounds){ var projection=this.getProjection(); var tr=new google.maps.LatLng(bounds.getNorthEast().lat(), bounds.getNorthEast().lng()); var bl=new google.maps.LatLng(bounds.getSouthWest().lat(), bounds.getSouthWest().lng()); var trPix=projection.fromLatLngToDivPixel(tr); trPix.x +=this.gridSize_; trPix.y -=this.gridSize_; var blPix=projection.fromLatLngToDivPixel(bl); blPix.x -=this.gridSize_; blPix.y +=this.gridSize_; var ne=projection.fromDivPixelToLatLng(trPix); var sw=projection.fromDivPixelToLatLng(blPix); bounds.extend(ne); bounds.extend(sw); return bounds; }; MarkerClusterer.prototype.redraw_=function (){ this.createClusters_(0); }; MarkerClusterer.prototype.resetViewport_=function (opt_hide){ var i, marker; for (i=0; i < this.clusters_.length; i++){ this.clusters_[i].remove(); } this.clusters_=[]; for (i=0; i < this.markers_.length; i++){ marker=this.markers_[i]; marker.isAdded=false; if(opt_hide){ marker.setMap(null); }} }; MarkerClusterer.prototype.distanceBetweenPoints_=function (p1, p2){ var R=6371; var dLat=(p2.lat() - p1.lat()) * Math.PI / 180; var dLon=(p2.lng() - p1.lng()) * Math.PI / 180; var a=Math.sin(dLat / 2) * Math.sin(dLat / 2) + Math.cos(p1.lat() * Math.PI / 180) * Math.cos(p2.lat() * Math.PI / 180) * Math.sin(dLon / 2) * Math.sin(dLon / 2); var c=2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)); var d=R * c; return d; }; MarkerClusterer.prototype.isMarkerInBounds_=function (marker, bounds){ return bounds.contains(marker.getPosition()); }; MarkerClusterer.prototype.addToClosestCluster_=function (marker){ var i, d, cluster, center; var distance=40000; var clusterToAddTo=null; for (i=0; i < this.clusters_.length; i++){ cluster=this.clusters_[i]; center=cluster.getCenter(); if(center){ d=this.distanceBetweenPoints_(center, marker.getPosition()); if(d < distance){ distance=d; clusterToAddTo=cluster; }} } if(clusterToAddTo&&clusterToAddTo.isMarkerInClusterBounds(marker)){ clusterToAddTo.addMarker(marker); }else{ cluster=new Cluster(this); cluster.addMarker(marker); this.clusters_.push(cluster); }}; MarkerClusterer.prototype.createClusters_=function (iFirst){ var i, marker; var mapBounds; var cMarkerClusterer=this; if(!this.ready_){ return; } if(iFirst===0){ google.maps.event.trigger(this, "clusteringbegin", this); if(typeof this.timerRefStatic!=="undefined"){ clearTimeout(this.timerRefStatic); delete this.timerRefStatic; }} if(this.getMap().getZoom() > 3){ mapBounds=new google.maps.LatLngBounds(this.getMap().getBounds().getSouthWest(), this.getMap().getBounds().getNorthEast()); }else{ mapBounds=new google.maps.LatLngBounds(new google.maps.LatLng(85.02070771743472, -178.48388434375), new google.maps.LatLng(-85.08136444384544, 178.00048865625)); } var bounds=this.getExtendedBounds(mapBounds); var iLast=Math.min(iFirst + this.batchSize_, this.markers_.length); for (i=iFirst; i < iLast; i++){ marker=this.markers_[i]; if(!marker.isAdded&&this.isMarkerInBounds_(marker, bounds)){ if(!this.ignoreHidden_||(this.ignoreHidden_&&marker.getVisible())){ this.addToClosestCluster_(marker); }} } if(iLast < this.markers_.length){ this.timerRefStatic=setTimeout(function (){ cMarkerClusterer.createClusters_(iLast); }, 0); }else{ delete this.timerRefStatic; google.maps.event.trigger(this, "clusteringend", this); }}; MarkerClusterer.prototype.extend=function (obj1, obj2){ return (function (object){ var property; for (property in object.prototype){ this.prototype[property]=object.prototype[property]; } return this; }).apply(obj1, [obj2]); }; MarkerClusterer.CALCULATOR=function (markers, numStyles){ var index=0; var title=""; var count=markers.length.toString(); var dv=count; while (dv!==0){ dv=parseInt(dv / 10, 10); index++; } index=Math.min(index, numStyles); return { text: count, index: index, title: title };}; MarkerClusterer.BATCH_SIZE=2000; MarkerClusterer.BATCH_SIZE_IE=500; MarkerClusterer.IMAGE_PATH="http://google-maps-utility-library-v3.googlecode.com/svn/trunk/markerclustererplus/images/m"; MarkerClusterer.IMAGE_EXTENSION="png"; MarkerClusterer.IMAGE_SIZES=[53, 56, 66, 78, 90]; if(typeof String.prototype.trim!=='function'){ String.prototype.trim=function(){ return this.replace(/^\s+|\s+$/g, ''); }}; function WpstateMarker(area, city, pin_price,poss,latlng, map,title,counter,image,id,price,single_first_type,single_first_action,link,i, rooms,baths,cleanprice,size,single_first_type_name,single_first_action_name,pin,custom_info,infoWindowIndex){ "use strict"; this.city=city; this.area=area; this.position=latlng; this.title=title; this.zIndex=counter; this.image=image; this.idul=id; this.price=price; this.pin_price=pin_price; this.category=single_first_type; this.action=single_first_action; this.link=link; this.infoWindowIndex=i; this.rooms=rooms; this.guest_no=baths; this.cleanprice=cleanprice; this.size=size; this.category_name=single_first_type_name; this.action_name=single_first_action_name; this.custom_info=custom_info; this.visible=true; this.draggable=false; this.optimized=true; this.opacity=1.0; this.pin=pin; this._omsData=null; this.spiderfied=false; this.div_=null; this.map_=map; this.setMap(map); } WpstateMarker.prototype=new google.maps.OverlayView(); WpstateMarker.prototype.onAdd=function(){ }; WpstateMarker.prototype.draw=function(){ var self=this; var div=this.div; if(!div){ div=this.div=document.createElement('div'); div.className='wpestate_marker '+wpestate_makeSafeForCSS(this.category_name.trim())+' '+wpestate_makeSafeForCSS(this.action_name.trim()); if(typeof(self.price)!=='undefined'){ if(mapfunctions_vars.use_price_pins_full_price==='no'){ div.innerHTML='
'+self.pin_price+'
'; }else{ div.innerHTML='
'+self.price+'
'; }} google.maps.event.addDomListener(div, "mouseout", function(event){ google.maps.event.trigger(self, "mouseout"); self.div.classList.remove("hover_z_pin"); }); google.maps.event.addDomListener(div, "click", function(event){ event.stopPropagation(); google.maps.event.trigger(self, "click"); }); google.maps.event.addDomListener(div, "mouseover", function(event){ google.maps.event.trigger(self, "mouseover"); self.div.className +=' hover_z_pin '; }); var panes=this.getPanes(); panes.overlayImage.appendChild(div); } var point=this.getProjection().fromLatLngToDivPixel(this.position); if(point){ div.style.left=(point.x+0) + 'px'; div.style.top=(point.y -14) + 'px'; }}; WpstateMarker.prototype.remove=function(){ if(this.div){ this.div.parentNode.removeChild(this.div); this.div=null; }}; WpstateMarker.prototype.getPosition=function(){ return this.position; }; WpstateMarker.prototype.setPosition=function(newlatlng){ this.position=newlatlng; var point=this.getProjection().fromLatLngToDivPixel(this.position); if(point){ this.div.style.left=(point.x+0) + 'px'; this.div.style.top=(point.y -14) + 'px'; }}; WpstateMarker.prototype.getDraggable=function(){ return false; }; WpstateMarker.prototype.getVisible=function(){ return this.visible; }; WpstateMarker.prototype.getMap=function(){ return this.map; }; WpstateMarker.prototype.setmap=function(map){ this.map=map; }; WpstateMarker.prototype.getZIndex=function(){ return this.zIndex; }; WpstateMarker.prototype.setZIndex=function(value){ this.zIndex=value; }; WpstateMarker.prototype.setVisible=function(value){ this.visible=value; }; WpstateMarker.prototype.getBounds=function(){ return new google.maps.LatLngBounds(this.position, this.position); }; WpstateMarker.prototype.fromLatLngToDivPixel=function(){ }; (function(){ var h=!0,u=null,v=!1; (function(){var A,B={}.hasOwnProperty,C=[].slice;if(((A=this.google)!=u?A.maps:void 0)!=u)this.OverlappingMarkerSpiderfier=function(){function w(b,d){var a,g,f,e,c=this;this.map=b;d==u&&(d={});for(a in d)B.call(d,a)&&(g=d[a],this[a]=g);this.e=new this.constructor.g(this.map);this.n();this.b={};e=["click","zoom_changed","maptypeid_changed"];g=0;for(f=e.length;gd)return this;g=this.j.splice(d,1)[0];f=0;for(e=g.length;fa||this.b[b].splice(a,1);return this};c.clearListeners=function(b){this.b[b]=[];return this};c.trigger=function(){var b,d,a,g,f,e;d=arguments[0];b=2<=arguments.length?C.call(arguments,1):[];d=(a=this.b[d])!=u?a:[];e=[];g=0;for(f=d.length;gb;a=0<=b?++e:--e)a=this.circleStartAngle+a*g,c.push(new s.Point(d.x+f*Math.cos(a),d.y+f*Math.sin(a)));return c};c.v=function(b,d){var a,g,f,e,c;f=this.spiralLengthStart;a=0;c=[];for(g=e=0;0<=b?eb;g=0<=b?++e:--e)a+=this.spiralFootSeparation/f+5E-4*g,g=new s.Point(d.x+f*Math.cos(a),d.y+f*Math.sin(a)),f+=y*this.spiralLengthFactor/a,c.push(g);return c};c.F=function(b,d){var a,g,f,e,c, m,l,x,n;e=b._omsData!=u;(!e||!this.keepSpiderfied)&&this.unspiderfy();if(e||this.map.getStreetView().getVisible()||"GoogleEarthAPI"===this.map.getMapTypeId())return this.trigger("click",b,d);e=[];c=[];a=this.nearbyDistance;m=a*a;f=this.c(b.position);n=this.a;l=0;for(x=n.length;l=this.circleSpiralSwitchover?this.v(q,a).reverse():this.u(q,a);a=function(){var a,d,k,q=this;k=[];a=0;for(d=e.length;a -1){ return true; }else{ return false; }} function wprentals_google_setMarkers(map, locations){ "use strict"; var custom_info,pin_price,beach, id, lat, lng, title, pin, counter, image, price, single_first_type, single_first_action, link, city, area, cleanprice, rooms, baths, size, single_first_type_name, single_first_action_name, map_open, myLatLng, selected_id, open_height, boxText, closed_height, width_browser, infobox_width, vertical_pan, myOptions,status, i, slug1, val1, how1, slug2, val2, how2, slug3, val3, how3, slug4, val4, how4, slug5, val5, how5, slug6, val6, how6, slug7, val7, how7, slug8, val8, how8; selected_id=parseInt(jQuery('#gmap_wrapper').attr('data-post_id'), 10); if(isNaN(selected_id)){ selected_id=parseInt(jQuery('#google_map_on_list').attr('data-post_id'), 10); } open_height=parseInt(mapfunctions_vars.open_height, 10); closed_height=parseInt(mapfunctions_vars.closed_height, 10); boxText=document.createElement("div"); width_browser=jQuery(window).width(); infobox_width=700; vertical_pan=-215; if(width_browser < 900){ infobox_width=500; } if(width_browser < 600){ infobox_width=400; } if(width_browser < 400){ infobox_width=200; } myOptions={ content: boxText, disableAutoPan: true, maxWidth: infobox_width, boxClass: "mybox", zIndex: null, closeBoxMargin: "-13px 0px 0px 0px", closeBoxURL: "", infoBoxClearance: new google.maps.Size(1, 1), isHidden: false, pane: "floatPane", enableEventPropagation: false }; infoBox=new InfoBox(myOptions); for (i=0; i < locations.length; i++){ beach=locations[i]; id=beach[10]; lat=beach[1]; lng=beach[2]; title=decodeURIComponent(beach[0]); pin=beach[8]; counter=beach[3]; image=decodeURIComponent(beach[4]); price=decodeURIComponent(beach[5]); single_first_type=decodeURIComponent(beach[6]); single_first_action=decodeURIComponent(beach[7]); link=decodeURIComponent(beach[9]); city=decodeURIComponent(beach[11]); area=decodeURIComponent(beach[12]); cleanprice=beach[13]; rooms=beach[14]; baths=beach[15]; size=beach[16]; single_first_type_name=decodeURIComponent(beach[17]); single_first_action_name=decodeURIComponent(beach[18]); status=decodeURIComponent(beach[19]); pin_price=decodeURIComponent(beach[20]); custom_info=decodeURIComponent(beach[21]); if(mapfunctions_vars.custom_search==='yes'){ i=1; slug1=beach[19+i]; val1=beach[20+i]; how1=beach[21+i]; slug2=beach[22+i]; val2=beach[23+i]; how2=beach[24+i]; slug3=beach[25+i]; val3=beach[26+i]; how3=beach[27+i]; slug4=beach[28+i]; val4=beach[29+i]; how4=beach[30+i]; slug5=beach[31+i]; val5=beach[32+i]; how5=beach[33+i]; slug6=beach[34+i]; val6=beach[35+i]; how6=beach[36+i]; slug7=beach[37+i]; val7=beach[38+i]; how7=beach[39+i]; slug8=beach[40+i]; val8=beach[41+i]; how8=beach[42+i]; } wpestate_createMarker(pin_price,infobox_width ,size, i, id, lat, lng, pin, title, counter, image, price, single_first_type, single_first_action, link, city, area, rooms, baths, cleanprice, slug1, val1, how1, slug2, val2, how2, slug3, val3, how3, slug4, val4, how4, slug5, val5, how5, slug6, val6, how6, slug7, val7, how7, slug8, val8, how8, single_first_type_name, single_first_action_name,status,custom_info); if(selected_id===id){ found_id=i; }} if(mapfunctions_vars.generated_pins!=='0'){ myLatLng=new google.maps.LatLng(lat, lng); if(map_is_pan===0){ wpestate_pan_to_last_pin(myLatLng); oms=new OverlappingMarkerSpiderfier(map); setOms(gmarkers); oms.addListener('spiderfy', function (markers){ }); oms.addListener('unspiderfy ', function (markers){ }); } map_is_pan=0; } if(mapfunctions_vars.is_prop_list==='1'||mapfunctions_vars.is_tax==='1'){ wpestate_show_pins_filters_from_file(); }} function wpestate_createMarker(pin_price,infobox_width, size, i, id, lat, lng, pin, title, counter, image, price, single_first_type, single_first_action, link, city, area, rooms, baths, cleanprice, slug1, val1, how1, slug2, val2, how2, slug3, val3, how3, slug4, val4, how4, slug5, val5, how5, slug6, val6, how6, slug7, val7, how7, slug8, val8, how8, single_first_type_name, single_first_action_name,status,custom_info){ "use strict"; var marker, myLatLng; var Titlex=jQuery('